package com.example.hehecat.yuejian1.mvp.presenter;

import android.util.Log;

import com.example.hehecat.yuejian1.mvp.contract.PictureListContract;
import com.example.hehecat.yuejian1.mvp.model.PictureListModel;
import com.example.hehecat.yuejian1.mvp.model.bean.PictureBean;

import java.util.List;

import rx.Subscriber;

import static com.chad.library.adapter.base.listener.SimpleClickListener.TAG;

public class PictureListPresenter implements PictureListContract.Presenter {

    private PictureListContract.View view;
    private PictureListContract.Model model;

    public PictureListPresenter(PictureListContract.View view){
        this.view = view;
        model = new PictureListModel();
    }

    @Override
    public void updateAdapterData() {
        model.getAllPictureData(new Subscriber<List<PictureBean>>() {
            @Override
            public void onCompleted() {
                Log.d(TAG, "onNext: "+"onCompleted");
            }

            @Override
            public void onError(Throwable e) {
                Log.d(TAG,"onNext:"+e.toString());
            }

            @Override
            public void onNext(List<PictureBean> pictureBeans) {
                view.updateAdapterData(pictureBeans);
                Log.d(TAG,"onNext:"+pictureBeans.get(0).getPicturename());
            }
        });
    }
}
